<?php  include("GuestAdd.php");  ?>


<?php

  if(isset($_POST['submit'])){
    
    $fname=$_POST['fname'];
    $lname=$_POST['lname'];
    $address=$_POST['address'];
    $district=$_POST['district'];
    $tel=$_POST['tel'];
    $email=$_POST['email'];
    $nic=$_POST['nic'];
    $sex    = isset($_POST['sex'])    ? $_POST['sex']    : null;
    $dob=$_POST['dob'];
    $notify    = isset($_POST['notify'])    ? $_POST['notify']    : null;
  
    $gmail=$facebook=$twitter=false;

   
    if(isset($notify)){
    foreach ($notify as $value) {

      if ($value=="gmail") {$gmail=true;}
      if ($value=="facebook") {$facebook=true;}
      if ($value=="twitter") {$twitter=true;}
      
    }
  }
   

    $sql="INSERT INTO employee(fname,lname,address,district,tel,email,nic,sex,dob,gmail,facebook,twitter)
    VALUES ('{$fname}','{$lname}','{$address}','{$district}','{$tel}','{$email}','{$nic}','{$sex}','{$dob}','{$gmail}','{$facebook}','{$twitter}')";

    $result=mysqli_Query($con,$sql);
  
    if (!$result)
    {
      die("database query failed".mysqli_error($con));
    }
    
      mysqli_close($con);

  }



?>


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>test form</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/custom.css" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
   <div class="container">
    <h3>Employee Registration</h3>
    <hr>
  <form class="form-horizontal" role="form" action="index.php" method="post">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">First Name</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="fname" placeholder="First Name" name="fname">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Last Name</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="lname" placeholder="Last Name" name="lname">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Address</label>
    <div class="col-sm-10">
      <textarea class="form-control" id="address" name="address"></textarea>
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">District</label>
    <div class="col-sm-10">
    <select name="district"  class="form-control" name="district" >
            <option value="matale" >matale</option>
            <option value="kandy">kandy</option>
            <option value="kandy">kandy</option>
            <option value="kurunagala">kurunagala</option>
            <option value="matara">matara</option>
            <option value="ratnapura">ratnapura</option>
            <option value="nuwaraeliya">nuwaraeliya</option>
            <option value="kalutara">kalutara</option>
            <option value="badilla">badilla</option>
            <option value="ampara">ampara</option>
    </select>
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Tel No.</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="tel_no." placeholder="Tel No." name="tel">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="email" placeholder="Email" name="email">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">NIC</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="nic" placeholder="NIC" name="nic">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Sex</label>
    <div class="col-sm-10">
      Male<input type="radio"  id="sex" name="sex" value="male">
      Female<input type="radio"  id="sex" name="sex" value="female">
    </div>
  </div
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">DOB</label>
    <div class="col-sm-10">
      <input type="date" class="form-control" id="dob" name="dob">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Notification</label>
    <div class="col-sm-10">
      gmail<input type="checkbox"  id="notify" name="notify[]" value="gmail">
      facebook<input type="checkbox"  id="notify" name="notify[]" value="facebook">
      twitter<input type="checkbox"  id="notify" name="notify[]" value="twitter">
    </div>
  </div>
  
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default" name="submit">Register</button>
    </div>
  </div>
</form>

</div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>